<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <button>按钮</button>
    <script>
        /**
         * 箭头函数不能作为构造函数
         * 箭头函数没有this绑定， this 指向 上一级上下文的this
         */
        // let student = (name) => {
        //     this.name = name;
        // }
        // let st1 = new student(); //报错：student is not a constructor
        

        var btn = document.querySelector('button');
        btn.onclick = () => {
            // console.log(this);//window
            setTimeout(() => {
                console.log(this); //window
            }, 2000)
            
        }

        // 变量的赋值规则

        // function fn1() {
        //     function fn2() {
        //         var a;
        //         function fn3() {
        //             a = 10;
        //         }
        //         fn3();
        //         console.log(a);
        //     }
        //     fn2();
        //     // console.log(a);
        // }
        // fn1();
    </script>
</body>
</html>